import '../public.dart';

class SellCardApi {
  /// 手机客户查询当前最高报价
  /// /clientSell/{cardTypeId}/{cardCategoryId}/query-max-quotation
  static Future<BaseResponse<CurrentMaxQuoteDto>> queryMaxQuotation({
    required int cardTypeId,
    required int cardCategoryId,
  }) async {
    final response = await HttpUtil().request(
      '/clientSell/$cardTypeId/$cardCategoryId/query-max-quotation',
      method: 'POST',
    );
    return BaseResponse<CurrentMaxQuoteDto>.fromJson(
      response,
      fromJsonT: (json) => CurrentMaxQuoteDto.fromJson(json),
    );
  }

  /// 售卖礼品卡
  /// /clientSell/sellCard
  static Future<BaseResponse<void>> sell(SellGiftCardDto params) async {
    final response = await HttpUtil().request(
      '/clientSell/sellCard',
      method: 'POST',
      data: params.toJson(),
    );
    return BaseResponse<void>.fromJson(response);
  }

  /// 分页查询售卖记录
  /// /clientSell/getRecordPage
  static Future<BaseResponse<PagedDataResponse<SellRecordPageResponseDto>>>
  getRecordPage(SellRecordPageRequestDto params) async {
    final response = await HttpUtil().request(
      '/clientSell/getRecordPage',
      method: 'POST',
      data: params.toJson(),
    );
    return BaseResponse<PagedDataResponse<SellRecordPageResponseDto>>.fromJson(
      response,
      fromJsonT: (json) =>
          PagedDataResponse<SellRecordPageResponseDto>.fromJson(
            json,
            (json2) => SellRecordPageResponseDto.fromJson(json2),
          ),
    );
  }

  /// 按核销报价*财务汇率*平台折扣比查询卡分类排序数据
  /// /clientSell/category-top
  static Future<BaseResponse<List<CategoryTopQuoteDetailDto>>>
  queryTopCategory() async {
    final response = await HttpUtil().request(
      '/clientSell/category-top',
      method: 'GET',
    );
    return BaseResponse<List<CategoryTopQuoteDetailDto>>.fromJson(
      response,
      fromJsonT: (json) => (json as List)
          .map((e) => CategoryTopQuoteDetailDto.fromJson(e))
          .toList(),
    );
  }
}
